package com.xcity.game.equip.suit4.impl;

import com.xcity.game.combat.Action;
import com.xcity.game.combat.ActionEffect;
import com.xcity.game.combat.Combat;
import com.xcity.game.combat.attr.CombatAttributeType;
import com.xcity.game.combat.unit.CombatUnit;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.equip.suit4.BaseSuit4;
import com.xcity.game.equip.template.EquipSuitEffectTemplate;

/**
 * 路易威登4件套<br/>
 * 受到伤害时{20}%的几率反弹受到的所有伤害
 * @author yang.li
 *
 */
public class Suit4LouisWeedon extends BaseSuit4 {

	public Suit4LouisWeedon(CombatUnit unit, EquipSuitEffectTemplate template) {
		super(unit, template);
	}

	@Override
	public void afterDamage(ActionEffect effect) {
		if (unit.getId() != effect.getUnitId()) {
			return;
		}
		int hpDelta = effect.getHpDelta();
		if (!effect.getUnit().isDied() && hpDelta < 0 && Combat.RND.nextInt(GameStaticConfig.percentBase) < template.getSuit4Param(0)) {
			Action act = new Action(effect.getUnit());
			effect.ref().ref().add(act);
			ActionEffect eff = act.addTarget(effect.ref().unit);
			eff.effect(CombatAttributeType.HP, hpDelta);
		}
	}

}
